package com.lich.service;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lich.dao.AppErrorMapper;
import com.lich.dao.AppErrorMapper;
import com.lich.entity.AppError;
import com.lich.entity.AppError;
import com.lich.entity.vo.Page;

@Service
public class AppErrorService {
	@Resource
	AppErrorMapper appErrorMapper;
	
	/**
	 * @description 添加
	 * @date 2016年8月31日
	 * @author luosf
	 * @param product
	 * @return
	 */
	@Transactional
	public int add(AppError appError) {
		return appErrorMapper.insert(appError);
	}

	/**
	 * @description 更新
	 * @date 2016年8月31日
	 * @author lich-thinkpad
	 * @param product
	 */
	public int update(AppError appError) {
		appErrorMapper.updateById(appError);
		return 1;
	}
	/**
	 * @description 获取一页
	 * @date 2016年8月31日
	 * @author lich-thinkpad
	 * @param pageParam
	 * @return
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 */
	public Page getPage(AppError appError) throws IllegalAccessException, InvocationTargetException {
		List<AppError> products = appErrorMapper.selectPage(appError);
		Page page = appError.getPage();
		int count = appErrorMapper.count(appError);
		page.setCount(count);
		page.setList(products);
		return page;
	}
	
	/**
	 * @description 获取所有数据
	 * @date 2016年8月31日
	 * @author lich-thinkpad
	 * @param pageParam
	 * @return
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 */
	public List<AppError> findAll(AppError appError) throws IllegalAccessException, InvocationTargetException {
		List<AppError> products = appErrorMapper.findAll(appError);
		
		return products;
	}
	
	/**
	 * @description 根据ID获取行
	 * @date 2016年8月31日
	 * @author lich-thinkpad
	 * @param pageParam
	 * @return
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 */
	public AppError selectById(Integer id) throws IllegalAccessException, InvocationTargetException {
		return appErrorMapper.selectById(id);
	}

	public int addList(List<AppError> appErrors) {
		return appErrorMapper.insertList(appErrors);
	}
	
}
